package cn.didi.feidi.androidorder.activity.personal;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import cn.didi.feidi.androidorder.R;
import cn.didi.feidi.androidorder.activity.SingleFragmentActivity;
import cn.didi.feidi.androidorder.assembly.CommomDialog;
import cn.didi.feidi.androidorder.assembly.FeidiActionBar;
import cn.didi.feidi.androidorder.fragment.personal.PersonLoginFragment;
import cn.didi.feidi.androidorder.manager.UserManager;

public class PersonLoginActivity extends SingleFragmentActivity {

    @Override
    protected Fragment createFragment(Bundle bundle) {
        return PersonLoginFragment.newInstance(bundle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initViews() {
        FeidiActionBar feidiActionBar = getFeidiActionBar();
        feidiActionBar.setTitleText("登陆");
        feidiActionBar.setSettingVisibility(View.GONE);
        feidiActionBar.setMessageVisibility(View.GONE);
    }

    @Override
    protected void initData() {
        if (UserManager.isLoginConflict()) {
            UserManager.setLoginConflict(false);
            showLoginConflictDialog(this);
        }
    }

    @Override
    protected void addListener() {

    }

    //显示下线通知
    private void showLoginConflictDialog(Context mContext) {
        new CommomDialog(mContext, R.style.dialog, "已在其他设备登录", new CommomDialog.OnCloseListener() {
            @Override
            public void onClick(Dialog dialog, boolean confirm) {
                if (confirm) {
                    dialog.dismiss();
                }
            }
        }, true, false).setTitle("下线通知").setPositiveButton("确认").show();
    }

}
